home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
ciarnv85.arc
/
HOST.4TH
< prev
next >
Wrap
Text File
|
1986-04-08
|
4KB
|
91 lines
( XECOM MODEM DEMO AND TERMINAL EMULATOR 1.00 )
( The name of this file is HOST.4TH. )
( The main loop of the Host computer terminal emulation is called HOST. )
( It is in the last segment of this program: H2.4TH. )
HEX
C" XE1" XE1 ( name of device. see device driver source listing )
: XO XE1 2 FOPEN FHNDL ! ; ( opens XE1 for read and write )
VARIABLE BUFF2 40 ALLOT ( buffer to hold bytes returned by function calls )
( The following 4 routines are the basic data, control/status read/write )
( functions. DA@ returns one data byte on the stack. DA! takes one byte )
( from the stack and stores it in the data port. CT@ returns the status )
( byte on the stack. CT! takes one byte from the stack and stores it in )
( the control port. These routines are coded in assembler according to )
( FORTH assembler conventions and use DOS function calls. )
( Note that you may simply poll the status register until the receiver )
( ready bit is on and then fetch a byte from location 2f8, data port, as )
( an alternate method. Or similarly poll the status register, 2f9, until )
( transmitter ready bit is on, and then store a data byte at 2f8. )
( This method is used in the voice routine called SAY. See VDICT0.4TH. )
CODE DA@ DX, DX XOR DX PUSH DX, SP MOV CX, # 0001 MOV
BX, FHNDL MOV AX, # 3F00 MOV INT21
NEXT JMP END-CODE
CODE CT@ DX, DX XOR DX PUSH DX, SP MOV CX, # 0001 MOV
BX, FHNDL MOV AX, # 4402 MOV INT21 AX, BUFF2 MOV
NEXT JMP END-CODE
CODE CT! DX, SP MOV CX, # 0001 MOV
BX, FHNDL MOV AX, # 4403 MOV INT21
DX POP NEXT JMP END-CODE
CODE DA! DX, SP MOV CX, # 0001 MOV
BX, FHNDL MOV AX, # 4000 MOV INT21
DX POP NEXT JMP END-CODE
( The following routines are for line analysis calculations. )
DECIMAL
CREATE K 2 ALLOT
CREATE LEV 2 ALLOT
CREATE TBASE 2 ALLOT ( VARIABLE TO HOLD NUMBER BASE e.g. HEX )
: D.0 BASE @ TBASE ! DECIMAL 10 >R ( outputs a double number with 3 ...)
SWAP OVER DABS <# #S ROT SIGN #> ( decimal places. )
R> OVER - SPACES TYPE TBASE @ BASE ! ;
: D.1 BASE @ TBASE ! DECIMAL 10 >R ( outputs a double number w/1 decimal )
SWAP OVER DABS <# # 46 HOLD #S ROT SIGN #>
R> OVER - SPACES TYPE TBASE @ BASE ! ;
: CU.000 ( D -- D ( CUBES A NUMBER THAT IS TIMES 1000 )
DDUP DDUP DROP 1000 M*/ DSWAP DROP 1000 M*/ ;
: 20LOG10N 0 K ! ( CALCULATES 20 LOG10 OF A DOUBLE )
( PRECISION NUMBER * 1000 AND RETURNS THE SAME )
BEGIN DDUP 2.000 D> WHILE 6 K +! 2 M/MOD
ROT DROP REPEAT
DDUP CU.000 1.000 D- DSWAP 1.000 D+
CU.000
DROP 1000 SWAP M*/
23 1 M*/ K @ 1000 M* D+ ; ( D.000 )
: S/N_DB ( SIGNAL TO NOISE IN DB ) ." SIGNAL/NOISE RATIO IS " LEV @ 3 < IF ." > 45 dB "
ELSE LEV @ 255 = IF ." < 4 dB "
ELSE 420.800 LEV @ M/MOD ROT DROP
20LOG10N .500 D+ 1 1000 M*/ D.0
." dB " THEN THEN ;
HEX
: SIGNEX DUP 7F > IF FF00 OR THEN ;
DECIMAL
CREATE DEV 2 ALLOT
: FREQ_DEV ." CARRIER FREQUENCY ERROR IS "
7372800. 1000 3314 DEV @ SIGNEX
- M*/ 2225.000 D- .50 D+ 1 100 M*/ D.1 ." Hz " ;
CREATE NN 2 ALLOT
: SLCALC NN @ DUP M* 1000 19391 M*/ NN @ 1000 M* 20LOG10N ( calculates ...)
D- 4.100 D- .500 D+ 1 1000 M*/ D.0 ; ( signal level. )
: SIG_LEV ." RECEIVED CARRIER LEVEL IS "
NN @ 3 < IF ." > -10 dBm "
ELSE NN @ 255 = IF ." < -40 dBm "
ELSE SLCALC ." dBm "
THEN
THEN ;
HEX
( End of line analysis calculations. )
==> B:H1.4TH